package com.asiainfo.hybridapp.other;

import android.os.Handler;
import android.os.Looper;

import java.util.List;

public abstract class OnRequestListResult_<T> implements JsoupResultWrapper.OnRequestListResult<T> {
    private Handler handler;

    public OnRequestListResult_() {
        handler = new Handler(Looper.getMainLooper());
    }

    public abstract void onSuccess_(final List<T> list, final String... msg);

    public abstract void onFail_(int code, String msg);

    @Override
    public void onSuccess(final List<T> list, final String... msg) {
        handler.post(new Runnable() {
            @Override
            public void run() {
                onSuccess_(list, msg);
            }
        });
    }

    @Override
    public void onFail(final int code, final String msg) {
        handler.post(new Runnable() {
            @Override
            public void run() {
                onFail_(code, msg);
            }
        });
    }
}
